//===============================================================================
// Microsoft patterns & practices
// Web Service Software Factory
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System.Drawing;
using System.Drawing.Imaging;

namespace Microsoft.Practices.Modeling.Dsl.Integration.Actions.DSL
{
    public class ExportDSLModelToBitmapAction : ConfigurableAction
    {
        #region Input Properties
        private Diagram diagram;

        [Input(Required=true)]
        public Diagram Diagram
        {
            get { return diagram; }
            set { diagram = value; }
        }
        #endregion

        #region Output Properties
        private Bitmap bitmap;

        [Output]
        public Bitmap Bitmap
        {
            get { return bitmap; }
            set { bitmap = value; }
        }

        #endregion

        public override void Execute()
        {
            try
            {
                Bitmap diagramBitmap = this.diagram.CreateBitmap(
                        this.diagram.NestedChildShapes,
                        Diagram.CreateBitmapPreference.FavorClarityOverSmallSize);

                this.bitmap = diagramBitmap;
            }
            catch 
            { }
            
        }

        //Not Implemented
        public override void Undo()
        {
            //Not Implemented
        }
    }
}
